#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright [Gtlions Lai].
# Create Date:
# Update Date:
"""summarization ahout this script.

detail ahout this script

   Class(): summarization about Class
   ...
   function(): summarization about function
   ...
"""
__authors__ = '"Gtlions Lai" <gtlions.l@qq.com>'

import sys
from PyQt4 import QtGui, QtCore


class Main(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setGeometry(300, 300, 100, 100)
        self.setWindowTitle("open file dialog")

        self.textedit = QtGui.QTextEdit()
        self.setCentralWidget(self.textedit)
        self.statusBar()
        self.setFocus()

        open = QtGui.QAction(QtGui.QIcon('icon.png'), 'open file', self)
        #open1 = QtGui.QAction(QtGui.QIcon('icon.png'), 'open file', self)
        open.setShortcut('Ctrl+o')
        open.setStatusTip('open a file pls')
        self.connect(open, QtCore.SIGNAL('triggered()'), self.showDialog)
        menubar = self.menuBar()
        file = menubar.addMenu('file')
        file.addAction(open)
        #file.addAction(open1)

    def showDialog(self):
        filename = QtGui.QFileDialog.getOpenFileName(self, 'open file ', './')
        file = open(filename)
        data = file.read()
        self.textedit.setText(data)
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    main = Main()
    main.show()
    sys.exit(app.exec_())